package com.example.threaddemo.ThreadDemo06;


public class MyThreadDemo extends Thread {


    @Override
    public void run() {

        while (true) {
            synchronized (ThreadDemo06.class) {
                if (ThreadDemo06.count == 10) {
                    break;
                } else {
                    ThreadDemo06.count--;
                    System.out.println(getName() +"发出了一份礼品，剩余" + ThreadDemo06.count + "份");
                }
            }
        }

    }
}
